home *** CD-ROM | disk | FTP | other *** search
File List | 1991-06-11 | 7.1 KB | 223 lines |
- GOTO here
- PROCEDURE wind_text(perc,color,title$,text$)
- ' ******************** TEXT WINDOW V1.2 ********************
- '
- ' This procedure will draw a graphics window centered on the screen
- ' in any resolution, and will allow scrolling of text in FOUR DIRECTIONS.
- ' Therefore, the width of the text sent to the procedure is unimportant
- ' and UNLIMITED.
- '
- ' Parameters:
- ' perc : Percentage of screen window takes up.
- ' The minimum percent is when the window is less
- ' than 18 characters...
- '
- ' color : 0-15 (The current color settings...)
- ' NOTE : If in med rez, colors 4 and beyond are
- ' the same as 3.
- ' If in high rez, use 0 or 1.
- ' ** '0' is a special default for "B&W", looks
- ' nice in all rez's!
- '
- ' title$ : String containing the title of the window.
- ' Title can be blank ("").
- ' Will be truncated if longer than size of window.
- '
- ' text$ : String containing the text for the window.
- ' IMPORTANT: To be built in this manner BEFORE calling
- ' this procedure :
- ' text$(0)="Put your text here..."
- ' text$(1)="Dimension your text string var"
- ' text$(2)=" to be of the correct size."
- ' text$(3)="Each line can be an UNLIMITED width"
- ' text$(4)="and will still be viewable."
- ' text$(5)="The output will look just like"
- ' text$(6)="it does in this listing..."
- ' text$(7)=""
- ' text$(8)="Etc, etc... "
- ' text$(9)="Blah blah blah"
- ' text$(10)=" ALWAYS END THE TEXT LIKE THIS:"
- ' text$(11)="\q"
- '
- ' IT IS YOUR RESPONSIBILITY TO END THE TEXT LIKE ABOVE--
- '
- ' Examples of use :
- '
- ' wind_text(55,2,"MAIN MENU",message$)
- '
- ' -or-
- '
- ' wperc=87
- ' wcolor=12
- ' wtitle$="PROGRAM HELP SECTION"
- ' dim text$(3)
- ' text$(0)="Press <ESC> to quit any function..."
- ' text$(1)=""
- ' text$(2)="Blah blah blah"
- ' text$(3)="\q"
- ' wind_text(wperc,wcolor,wtitle$,text$)
- '
- '
- title=-1
- IF title$=""
- title=0
- ENDIF
- rez=XBIOS(4) ! 0=low, 1=med, 2=hgh
- IF rez=0
- rezx=1 ! Used for screen formatting
- rezy=1
- scr_col=40 ! 40 columns
- scr_width=320 ! Screen width
- scr_length=200 ! Screen length
- ELSE
- rezx=1
- scr_col=80 ! 80 columns
- scr_width=640 ! Screen width
- IF rez=1
- rezy=1
- scr_length=200 ! Screen length
- ELSE
- scr_length=400 ! "
- rezy=2
- ENDIF
- ENDIF
- '
- width=INT(scr_col*(perc/100)) ! Width is certain percentage of screen
- IF width<19
- PRINT "Width is too small for current resolution!"
- GOTO fault
- ENDIF
- ' ***** Draw window *****
- IF color>0
- DEFFILL color,2,8
- ELSE
- DEFFILL 0,0,0
- ENDIF
- upperleftx=INT((scr_width/2)-((width/2)*(8*rezx)))-(2*rezx)
- upperlefty=INT((scr_length/2)-((20/2)*(8*rezy)))-(4*rezy)
- lowerrightx=(upperleftx+(width*(8*rezx)))-(1*rezx)
- lowerrighty=(upperlefty+(20*(8*rezy)))-(2*rezy)
- left_drawx=INT(upperleftx-(2*rezx))
- left_drawy=INT(upperlefty-(2*rezy))
- right_drawx=INT(lowerrightx+(2*rezx))
- right_drawy=INT(lowerrighty+(2*rezy))
- GET left_drawx,left_drawy,right_drawx,right_drawy,scr$
- PBOX left_drawx,left_drawy,right_drawx,right_drawy
- BOX left_drawx,left_drawy,right_drawx,right_drawy
- ulx_pro=INT(upperleftx+((8*width)*rezx)) ! Proportionate up-left
- LINE left_drawx,INT(upperlefty+(8*rezy)),ulx_pro,INT(upperlefty+(8*rezy))
- LINE left_drawx,INT(lowerrighty-(8*rezy)),ulx_pro,INT(lowerrighty-(8*rezy))
- ' ***** Decorate window *****
- IF color>0
- cl$="c"+STR$(color-1)
- PRINT CHR$(27)+LEFT$(cl$,2);
- IF rez=0
- bl$="b"+STR$(color+1)
- PRINT CHR$(27)+LEFT$(bl$,2);
- ENDIF
- ENDIF
- title_len=LEN(title$)
- IF title_len>=width
- j$=SPACE$(width-1)
- LSET j$=title$
- title$=j$
- title_len=width-1
- ENDIF
- PRINT AT(((upperleftx/(8*rezx))+((width/2)-(title_len/2))+1),(upperlefty/(8*rezy))+1);title$;
- PRINT AT(((upperleftx/(8*rezx))+((width/2)-8)+1),(upperlefty/(8*rezy))+20);
- OUT 5,2 ! Draw arrows
- PRINT ",";
- OUT 5,1
- PRINT ",";
- OUT 5,4
- PRINT ",";
- OUT 5,3
- PRINT ", ESC=Exit";
- ' ***** Fill window with text *****
- just$=SPACE$(width-1) ! To keep overflow from going out of window
- top=0 ! Starting line to put at top
- tot_len=-1
- w_size=16
- longest=width-2
- REPEAT
- INC tot_len
- t$=text$(tot_len)
- lt=LEN(text$(tot_len))
- IF lt>longest
- longest=lt
- ENDIF
- UNTIL (t$="\q" OR t$="\Q") ! MUST HAVE A "\Q" or "\q" !!!!
- update=-1
- left=1 ! Set left pos'n to beginning
- lmar=(upperleftx/8)+2
- REPEAT
- press=0
- IF INP?(2)
- press=INP(2)
- ENDIF
- IF (press=200 AND top>0) ! If pressed UP
- update=-1
- DEC top
- ENDIF
- IF (press=208 AND ((top+16)<tot_len)) ! If pressed DOWN
- update=-1
- INC top
- ENDIF
- IF (press=203 AND left>1) ! If pressed LEFT
- update=-1
- DEC left
- ENDIF
- IF (press=205 AND (left+(width-2))<=longest) ! If pressed RIGHT
- update=-1
- INC left
- ENDIF
- IF update=-1
- IF ((tot_len-top)<w_size) ! If all is less than size of window
- FOR rows=0 TO (tot_len-top)-1
- LSET just$=MID$(text$(rows+top),left,width-1)
- PRINT AT(lmar,5+rows);just$;
- NEXT rows
- ELSE
- FOR rows=0 TO 15
- LSET just$=MID$(text$(rows+top),left,width-1)
- PRINT AT(lmar,5+rows);just$;
- NEXT rows
- ENDIF
- ENDIF
- update=0
- UNTIL (press=27)
- '
- fault:
- PAUSE 5
- PUT INT(upperleftx-(2*rezx)),(upperlefty-(2*rezy)),scr$
- CLR scr$
- PRINT CHR$(27)+"c0";
- PRINT CHR$(27)+"b3";
- RETURN
- '
- PROCEDURE fill_text
- DIM text$(100)
- ctr=0
- READ t$
- title$=t$
- REPEAT
- READ t$
- text$(ctr)=t$
- INC ctr
- UNTIL (t$="\q")
- DATA Dennis' Super Dooper Menu!!!!!!
- DATA Hello, this is a test of the emergency broadcasting system...,I repeat -- this is ONLY a test!
- DATA I am just about finished filling up the menu so I will go soon!,"",But wait! Maybe not!
- DATA I figured I'd stay around a while longer!,\q
- RETURN
- '
- here:
- PRINT AT(1,1);
- FOR t=1 TO 23
- PRINT AT(1,t);STRING$(39,"*");
- NEXT t
- fill_text
- REPEAT
- wind_text(INT(100*RND(0)),0,title$,text$)
- UNTIL (left=2)
-